define(['jquery','cookie','user','util','footer','header'],function($,cookie,user,util,footer,header){
	var baseUrl='/index.php/',
	    wxKey = 'SOWXOPENID',
	    timeout=10000,
	    order,
	    goods,
	    qrcode,
	    initWxTimer,//微信appid定时器
	    wxid=$.cookie(wxKey);
	$.ajaxSetup({
	   dataType: 'json',
	   timeout:timeout,
	   complete:function(res,status){
	   	  var data;
	      if(status=='success'&&res.readyState==4&&res.status==200&&res.responseJSON){
	          data=res.responseJSON;
	          if(data.errorcode===-3004||data.retcode==='2'){
	             user.loginOut();
	          }else if(data.retcode&&data.retcode!='0'){
	             console.log(util.getError(data.retcode));
	          }
	      }
	   }
	})
	
    return {
    	setOrder: function (o) {
    	   order=o;
    	},
    	getOrder: function (o){
    	   return order;
    	},
    	setGoods: function (o) {
    	    goods = o;
    	},
    	getGoods: function () {
    		return goods;
    	},
    	userInfo:function(cb,errcb){
    		var url=util.url('user');
    	    $.ajax({
    		    url:url,
    		    timeout:120000,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb == 'function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='用户资金信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	userCore:function(cb){
    		var url=util.url('userCore');
    	    $.ajax({
    		    url:url,
    		    timeout:120000,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='用户信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	notice:function(cb){
    		var url=util.url('notice');
    	    $.getJSON(url,{count:1},function(rs){
    	        cb(rs);
    	    })
    	},
    	noticeRead:function(id){
    		$.getJSON(util.url('noticeback'),{noticeid:id},function(rs){
    	    })
    	},
    	init:function(boot){
    		header.init();
    		footer.init();
    		
      		if(location.hash.split('/')[1]=='agent'){//下标：2推荐人uid，3机构id
      			var agentid = location.hash.split('/')[2],
      				agentpid = location.hash.split('/')[3];
  				user.addAgent(agentid,agentpid);
      		}
    		//boot(); routeConfig.boot
    		util.isWxBrowser()?this.initWx(boot):boot(); 
    	},
    	initFooter:footer.setFocus,
    	footerShow:footer.setShow,
    	headerShow:header.setShow,
    	headerTitle:header.setTitle,
    	headerRightTitle:header.setRightTitle,
    	headerLeftLink:header.setLeftLink,
    	headerRightLink:header.setRightLink,
    	initWxTimerGo:function(){
    		var that=this;
    		initWxTimer = setTimeout(function(){
    			that.initWx(function(){});
    		},5000);
    	},
    	initWx:function(boot){
		    var txUrl=function(appid){
		    		var target=window.wxProxy?(window.wxProxy+'?backUrl='+location.href):location.href;
			    	return 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appid+'&redirect_uri='+encodeURIComponent(target)+'&response_type=code&scope=snsapi_base#wechat_redirect'
			    },
			    result,
			    that=this,
		        location=window.location,
		        host = window.wxdomain?window.wxdomain:location.hostname,
	            queryObj=util.queryToObj(location.search.substring(1)),
	            errCallBack = function(){
//	            	that.initWxTimerGo();
		    	    setTimeout(boot(),1000);
	            };

		   	if(wxid){
		   		boot();
		   	}else if(queryObj.code){
//		   		 util.loadMsg('微信openid获取中……');
		   		 console.log('微信openid获取中……');
		   		 $.ajax({
				    url:util.url('wxid'),
				    dataType:'json',
				    data:{wxcode:queryObj.code,wxdomain:host},
				    success:function(rs){
//				    	util.loadMsg('');
				    	if(rs.retcode==='0'){
			    	    	user.setIsRegister(rs.exist);
			    	    	wxid=rs.wxid;
			    	    	if(rs.exist==='1'){
			    	    	   user.setUid(rs.data.uid);
			    	    	}
			    	    	user.setWeixinid(wxid);//$.cookie(wxKey,wxid,{expires:7});
			    	    	boot();
				    	}else{
				    	    util.msg('获取微信openid失败！');
				    	    errCallBack();
				    	}
				    },
				    error:function(){
				        util.msg('微信openid获取失败');
				        errCallBack();
				    }
				});
		   	}else {
	            that.appid(function(rs){
			    	if(rs.retcode=='0'){
			    	    if(rs.appid){
			    	    	user.setAppid(rs.appid);
                            window.location.href=txUrl(rs.appid);
			    	    }
			    	}else if(rs.retcode=='19'){
			    	    util.msg('系统appid不存在，请联系管理员！');
						errCallBack();
			    	}else{
			    		util.dealErrorCode(rs.retcode);
			    		errCallBack();
			    	}
			    	
				},
				function(){//err
					util.msg('系统appid获取失败');
					errCallBack();
				});
			}
		},
		isReg:function(o){
			 $.ajax({
	   			url:util.url('isReg'),
	   			data:{wxid:$.trim(wxid)},
	   			method:'post',
	   			dataType:'json',
	   			success:o.success,
	   			error:o.error
	   		});
		},
		getWxid:function(){
		   return wxid;
		},
    	login:function(data,cb){
    	    $.ajax({
    	      url:util.url('login'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      timeout:timeout,
    	      beforeSend: function () {
		          $("#loginBtn").attr("disabled", true).val('登录中……');
		          
		      },
		      error: function () {
	              util.msg("网络异常请再试试");
	              $("#loginBtn").removeAttr("disabled").val('登录');
	          },
    	      success:cb
    	    });
    	},
    	appid:function(cb,err){
    		var host = window.wxdomain?window.wxdomain:location.hostname;
//  		util.loadMsg('系统信息获取中');
    	    $.ajax({
			    url:util.url('appid'),
			    dataType:'json',
			    data:{
			       wxdomain:host
			    },
			    complete:function(){
//			       util.loadMsg('');
			    },
			    success:cb,
			    error:function(){
				    if(typeof err=='function')  err;
			    }
			});	
    	},
    	holdOrders:function(data,cb){//我的持仓单
    	   $.ajax({
    	      url:util.url('holdOrders'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	doneOrders:function(o){
    	    $.ajax({
    	      	url:util.url('doneOrders'),
    	      	data:o.data,
    	      	method:'get',
    	      	dataType:'json',
    	      	success:o.success
    	    });
    	},
    	subscription:function(data,cb,errcb){ //当前认购查询 c=26
    	   $.ajax({
    	      url:util.url('subscription'),
    	      data:data,
    	      dataType:'json',
    	      success:cb,
    	      error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载当日认购失败！';
    		    	util.msg(error);
    		    }
    	    });
    	},
    	subscriptionHis:function(data,cb,errcb){ //历史认购 c=27
    	   $.ajax({
    	      url:util.url('subscriptionHis'),
    	      data:data,
    	      dataType:'json',
    	      success:cb,
    	      error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载历史认购失败！';
    		    	util.msg(error);
    		    }
    	    });
    	},
    	createLtOrder:function(data,cb){ //挂单买入
    	   $.ajax({
    	      url:util.url('createLtOrder'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	sellLtOrder:function(data,cb){ //挂单卖出
    	   $.ajax({
    	      url:util.url('sellLtOrder'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	cancelLtOrder:function(data,cb){ //撤销挂单
    	   $.ajax({
    	      url:util.url('cancelLtOrder'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	createLtOrderCater:function(data,cb){ //应价买入
    	   $.ajax({
    	      url:util.url('createLtOrderCater'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	ltsellCount:function(data,cb){ //应价卖查询
    		data.direct='s';
    	   $.ajax({
    	      url:util.url('ltsellCount'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	ltbuyCount:function(data,cb){ //应价买入查询
    		data.direct='b';
    	   $.ajax({
    	      url:util.url('ltbuyCount'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	sellOrderCater:function(data,cb){ //应价卖出
    	   $.ajax({
    	      url:util.url('sellOrderCater'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	createSlOrder:function(data,cb){ //认购
    	   $.ajax({
    	      url:util.url('createSlOrder'),
    	      data:data,
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	orders:function(data,cb){
    	   $.ajax({
    	      url:util.url('orders'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	ordersn:function(data,cb,error){
    	   $.ajax({
    	      url:util.url('ordersn'),
    	      data:data,
    	      method:'get',
    	      dataType:'json',
    	      success:cb,
    	      error:error
    	    });
    	},
    	order:function(opensn,cb){
    	   $.ajax({
    	      url:util.url('orders'),
    	      data:{o:opensn},
    	      method:'get',
    	      dataType:'json',
    	      success:cb
    	    });
    	},
    	quotation:function(o){
    		var data = {
    		    datatype :0,
    		    count: 1
    		},
    		that=this;

    		data = $.extend({},data,o.data);
    			
    		$.ajax({
    			url:util.url('quotation'),
    		    success:function(rs){
    		    	o.success(rs)
    		    },
    		    data:data,
    		    error:function(xhr,status){
    		    	if(typeof o.error=='function'){
	    		    	o.error(xhr,status);return;
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载行情数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	kDay:function(o){//日K线
    		var data = {
    		    datatype :100,
    		    count: 30
    		},
    		that=this;

    		data = $.extend({},data,o.data);
    			
    		$.ajax({
    			url:util.url('quotation'),
    		    success:function(rs){
    		    	o.success(rs)
    		    },
    		    data:data,
    		    error:function(xhr,status){
    		    	if(typeof o.error=='function'){
	    		    	o.error(xhr,status);return;
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载日K数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	quotations:function(data,cb,errcb){
    		$.ajax({
    			url:util.url('quotations'),
    		    success:cb,
    		    data:data,
    		    error:function(xhr,status){
    		    	if(typeof errcb=='function'){
	    		    	errcb(xhr,status);return;
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载行情数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	setTitle:util.setTitle,
    	getWxid:function(){
    		return $.cookie(wxKey);
    	},
    	goodsInfo:function(o){
    		var data;
    		$.ajax({
    			url:util.url('goods'),
    			timeout:timeout,
    			data:o.data||{type:1},
    		    dataType:'json',
    		    success:function(rs){
    		    	o.success(rs)
    		    },
    		    error:function(xhr,status){
    		    	if(typeof o.error=='function'){
    		    		o.error(xhr,status);
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载商品数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	groupInfo:function(cb,errcb){
    		var data;
    		$.ajax({
    			url:util.url('group'),
    		    success:function(rs){
    		    	cb(rs)
    		    },
    		    error:function(xhr,status){
    		    	if(typeof errcb=='function'){
    		    		errcb(xhr,status);
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载商品组数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	showQrcode:function(){
    	   var host = window.wxdomain?window.wxdomain:location.host,
    	       isSubscribe= user.getSubscribe() && user.getSubscribe()==='1' ? true : false,
    	       showCode=false;
//  	   if(!util.isWxBrowser())return false;
//  	   if(!user.isRegister()||user.getSubscribe()) return false;//先注册后关注
    	   if(isSubscribe){
    	   		location.hash="#/";
    	   }else{
	    	   // 获取公众号二维码
	    	   location.hash='#/index/subscribe';
    	   }
    	   return showCode;
    	},
    	subscribe:function(cb){
    	   var host = window.wxdomain?window.wxdomain:location.host;
    	   $.ajax({
    			url:util.url('subscribe'),
    		    async:false,
    		    dataType:'json',
    		    data:{wxid:$.cookie('SOWXOPENID'),wxdomain:host},
    		    success:cb
    	   });
    	},
    	getQrcode:function(){
    	   if(qrcode)return qrcode;
    	},
    	noticeList:function(data,cb){
    	    $.getJSON(util.url('noticeList'),data,cb)
    	},
    	customer:function(data,cb){
    	    $.getJSON(util.url('customer'),data,cb)
    	},
    	articleList:function(data,cb){
    	    $.getJSON(util.url('articleList'),data,cb)
    	},
    	noticeDetail:function(data,cb){
    	    $.getJSON(util.url('noticeDetail'),data,cb)
    	},
    	articleDetail:function(data,cb){
    	    $.getJSON(util.url('articleDetail'),data,cb)
    	},
    	createOrder:function(o){
    		var params={
	    		   ordermode:49
	    		},
	    		data=o.data;
	    		
    		$.extend(params,data);
    	    $.ajax({
    	       url:util.url('createOrder'),
    	       data:params,
    	       timeout:90000,
    	       dataType: 'json',
	           beforeSend:o.beforeSend,
    	       success:function(rs){
    	       	   o.cb(rs);
    	       },
    	       error:function(){
    	          o.error();
    	       }
    	    })
    	},
    	closeOrder:function(data,cb){
    		var params={
	    		};
	    		
    		$.extend(params,data);
    	    $.getJSON(util.url('closeOrder'),params,cb)
    	},
    	closeOrderAll:function(cb){
    		var params={
    		   ordersn:'-1',
    		   orderamount:1
    		}
    	    $.getJSON(util.url('closeOrderAll'),params,cb)
    	},
    	couponsAll:function(cb){
    		$.ajax({
    		    url:util.url('couponsAll'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载赢家券数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	allowFund:function(cb,errcb){
    		$.ajax({
    		    url:util.url('allowFund'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb == 'function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载可用金额失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	channels:function(cb,errcb){ //银行通道
    		$.ajax({
    		    url:util.url('channels'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb == 'function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载通道失败，请刷新重试';
    		    	util.msg(error);
    		    }
    		})
    	},
    	userchannels:function(cb){
    		$.ajax({
    		    url:util.url('userchannels'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载用户通道失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	slgoodsCount:function(data,cb){//认购商品统计信息
    		$.ajax({
    		    url:util.url('slgoodsCount'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载认购统计信息失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	ltOrders:function(data,cb){//当日挂单（委托单）
    		$.ajax({
    		    url:util.url('ltOrders'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载挂单失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	ltOrdersHis:function(data,cb){//历史挂单（委托单）
    		$.ajax({
    		    url:util.url('ltOrdersHis'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载挂单失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	tradesOrderHis:function(data,cb,errcb){ //成交单历史
    		$.ajax({
    		    url:util.url('tradesHis'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载历史成交单失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	tradesOrderNow:function(data,cb,errcb){ //成交单当日
    		$.ajax({
    		    url:util.url('trades'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载当日成交单失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	modifyOrder:function(data,cb){
    		$.ajax({
    		    url:util.url('modifyOrder'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='修改止盈止损失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	fundFlow:function(data,cb,errcb){
    		$.ajax({
    		    url:util.url('fundFlow'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载收支名细失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	fundFlowHistory:function(data,cb,errcb){
    		$.ajax({
    		    url:util.url('fundFlowHistory'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载收支名细失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	privinces:function(cb){
    		$.ajax({
    		    url:util.url('privinces'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载省会数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	citys:function(provincecode,cb){
    		$.ajax({
    		    url:util.url('privinces'),
    		    data:{provincecode:provincecode},
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载城市数据失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	banks:function(cb,errcb){
    		$.ajax({
    		    url:util.url('banks'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb == 'function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载开户行数据失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	captcha:function(cb){
    		$.ajax({
    		    url:util.url('captcha'),
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载验证码失败！';
    		    	util.msg(error);
    		    }
    		})
    	},
    	charge:function(data,cb){
    		$.ajax({
    		    url:util.url('charge'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='';
    		    	util.msg(error);
    		    }
    		})
    	},
    	cash:function(data,cb){
    		$.ajax({
    		    url:util.url('cash'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='';
    		    	util.msg(error);
    		    }
    		})
    	},
    	sendSMS:function(o){
    	    $.ajax({
    		    url:util.url('sms'),
    		    data:{
    		       mobile:o.mobile,
    		       imgcode:o.code
    		    },
    		    timeout:120000,
    		    success:function(rs){
    		       if(rs.retcode!='0'){
				       util.dealErrorCode(rs.retcode);
				   } 
    		       o.callback(rs);  
    		    },
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='发送短信失败！';
    		    	util.msg(error);
    		    	o.error();
    		    }
    		});
    	},
    	bind:function(o,cb){
    	    $.ajax({
    		    url:util.url('bind'),
    		    data:o,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='绑定失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	unBind:function(o,cb){
    	    $.ajax({
    		    url:util.url('unbind'),
    		    data:o,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='解绑失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	register:function(data,cb,errcb){
    	    $.ajax({
    		    url:util.url('register'),
    		    data:data,
    		    success:cb, 
    		    method:'get',//必须是get
    		    error:function(xhr,status){
    		    	if(typeof errcb == 'function'){
    		    		errcb(xhr,status);
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='注册失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	commission:function(o,cb,errcb){
    	    $.ajax({
    		    url:util.url('commission'),
    		    data:o,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='查询失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	pwdCheck:function(o,cb){
    	    $.ajax({
    		    url:util.url('pwdCheck'),
    		    data:o,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='验证失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	changePwd:function(data,cb){
    	    $.ajax({
    		    url:util.url('changePwd'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='修改失败！';
    		    	util.msg(error);
    		    	o.error();
    		    }
    		});
    	},
    	resetPwd:function(data,cb){
    	    $.ajax({
    		    url:util.url('resetPwd'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='重置失败！';
    		    	util.msg(error);
    		    	o.error();
    		    }
    		});
    	},
//  	wxinfo:function(code,cb){
//  		var host = this.getHost();
//  	    $.ajax({
//  		    url:util.url('wxinfo'),
//  		    data:{code:code,wxdomain:host},
//  		    timeout:120000,
//  		    success:cb,    
//  		    error:function(xhr,status){
//  		    	var error=status=='timeout'?'网络超时，':'';
//  		    	error+='用户信息加载失败！';
//  		    	util.msg(error);
//  		    }
//  		});
//  	},
    	getHost:function(){
    		return window.wxdomain?window.wxdomain:location.host;
    	},
    	points:function(o,cb){
    		$.ajax({
    		    url:util.url('points'),
    		    data:o,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='积分信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	userPoints:function(cb){
    		$.ajax({
    		    url:util.url('userPoints'),
    		    success:cb,  
    		    timeout:300000,
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='用户积分信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	mobileToWxid:function(o){
    	    $.ajax({
    		    url:util.url('mobileToWxid'),
    		    data:o.data,
    		    success:o.success,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='加载用户信息失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	loginOut:function(o){
    	   $.ajax({
    	       url:util.url('loginOut'),
    	       success:o.success,
    	       error:o.error
    	   })
    	},
    	notice:function(id,cb){//一条公告
    		$.ajax({
    		    url:util.url('notice'),
    		    data:{noticeid:id},
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='公告信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	notices:function(data,cb,errcb){//公告列表
    		$.ajax({
    		    url:util.url('notices'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='公告信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	noticesLogin:function(data,cb,errcb){//公告列表
    		$.ajax({
    		    url:util.url('noticesLogin'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	typeof errcb=='function' && errcb(xhr,status);
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='公告信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	queryGoodHold:function(data,cb){//持仓汇总
    		$.ajax({
    		    url:util.url('queryGoodHold'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='持仓汇总信息加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	flashsaleQuery:function(data,cb){//查询抢购计划
    		//c=51&beingdate=2017-03-11&endate=2017-03-11
    		$.ajax({
    		    url:util.url('flashsaleQuery'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='抢购计划加载失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	flashsale:function(data,cb){//抢购
    		//c=52&saleid=1&goodscode=000001&purchasenum=1
    		$.ajax({
    		    url:util.url('flashsale'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='抢购失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	wxavatar:function(data,cb,errcb){//微信头像
    		//c=53&wxid=&wxdomain=&
    		$.ajax({
    		    url:util.url('wxavatar'),
    		    async:false,
    		    dataType:'json',
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	if(typeof errcb=='function'){
    		    		errcb(xhr,status);
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='获取微信头像失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	ltGoodsNewest:function(data,cb,errcb){
    		//最新挂单买卖数量价格获取 cgi-bin/zl_cgi?c=5&goodscode=000003&direct=b b 挂单买入 s 挂单卖出
    		$.ajax({
    		    url:util.url('ltGoodsNewest'),
    		    data:data,
    		    success:cb,    
    		    error:function(xhr,status){
    		    	if(typeof errcb=='function'){
    		    		errcb(xhr,status);
    		    	}
    		    	var error=status=='timeout'?'网络超时，':'';
    		    	error+='获取最新挂单数据失败！';
    		    	util.msg(error);
    		    }
    		});
    	},
    	goodsDesc:function(goodscode,suc,err){
    		$.ajax({
                url: C('img_upload_path_goods_desc') + 'upload/json/' +goodscode + '.json',
                dataType: 'json',
                success: suc,
                error: err
           });
    	},
    	wxshare:function(data,suc,err){
    		$.ajax({
                url:util.url('wxshare'),
                data:data,
                dataType: 'json',
                success: suc,
                error: err
            })
    	},
    	transferSub:function(data,suc,err){//定向交易申请
    		//=57&goodscode=&direct=&orderprice=&mobile=&checkcode=
    		$.ajax({
                url:util.url('transferSub'),
                data:data,
                dataType: 'json',
                success: suc,
                error: err
            })
    	}
    }
})